import Vue from 'vue'
import Vuex from 'vuex'
import { getUserList } from '@/api/user'
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    userList: [],
    reqData: {
      query: "",
      pagenum: 1,
      pagesize: 2,
    }
  },
  mutations: {
    setUserData(state,data) {
      state.userList = data
    }
  },
  actions: {
    async getUser(ctx, payload) {
      const { data: res } = await getUserList(ctx.state.reqData)
      ctx.commit('setUserData',res.data.users)
    }
  },
  modules: {
  }
})
